<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>全选</title>
</head>
<body>
    <div>
        <input type="checkbox" id="all">
        <ul id="list">
            <li>
                <input type="checkbox">
            </li>
            <li>
                <input type="checkbox">
            </li>
            <li>
                <input type="checkbox">
            </li>
            <li>
                <input type="checkbox">
            </li>
            <li>
                <input type="checkbox">
            </li>
            <li>
                <input type="checkbox">
            </li>
        </ul>
    </div>

    <script>
        /* let list = document.getElementById("list");  
        let checkboxs = list.getElementsByTagName("input");
        let checkAll = document.getElementById("all");
        checkAll.onchange = function () {
            if(checkAll.checked){
                for(let i=0;i<checkboxs.length;i++){
                    checkboxs[i].checked = true;
                }
            }else {
                for(let i=0;i<checkboxs.length;i++){
                    checkboxs[i].checked = false;
                }
            }
        }

         for(let i=0;i<checkboxs.length;i++){
            checkboxs[i].onchange = function () {
                if(this.checked!=true){
                    checkAll.checked=false;
                }
            }
        } */
        
        let a = [1,1,0,0,1,1,1,0,0,1];
        let b = [];
        let num = 0;
        for(let i=0;i<a.length;i++){
            let item = a[i];
            if(item==0){
                if(num!=0){
                    b.push(num);
                }
                num=0;
                continue;
            }else{
                num++;
            }
            console.log(num);
            
            
        }
        console.log(b);
        



    
    </script>
</body>
</html>